<?php

namespace App\Http\Controllers\Wechat;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Ask;
use App\Http\Requests\Api\ApiRequest;

class AskController extends Controller
{
    public function index(ApiRequest $request)
    {
    	$rs['status']        = true;
    	$where['pid']        = 0;   
        $where['product_id'] = $request->product_id; 	
    	 
    	$list = Ask::where($where)
    						->orderBy('id','asc')
    						->get();
    	$rs['data'] = $list;
    	return response()->json($rs);					

    } 

    public function add(ApiRequest $request)
    {
        $rs['status'] = true;
        $data = $request->pure();           
        $flag = Ask::create($data);
        $rs['data'] = $flag;
        return response()->json($rs);   
    }
}
